package commonClass.ThreadLocalTest;

public class Client {
	public static void main(String[] args) throws InterruptedException {
		Server();
		ThreadLocalServer();
	}

	public static void Server() throws InterruptedException{
		//---主线程设置Bean
		final Server server=new Server();
		server.setBean("aa");
		//---第二个线程设置Bean
		Thread secondThread = new Thread(new Runnable(){
            public void run(){
            	server.setBean("bb");
            }
        });
		secondThread.start();
        Thread.sleep(10);
        
        //---主线程输出
		System.out.println(server.getBean());
	}
	
	public static void ThreadLocalServer() throws InterruptedException{
		//---主线程设置Bean
		final ThreadLoaclServer server=new ThreadLoaclServer();
		server.setBean("aa");
		//---第二个线程设置Bean
		Thread secondThread = new Thread(new Runnable(){
            public void run(){
            	server.setBean("bb");
            }
        });
		secondThread.start();
        Thread.sleep(10);
        
        //---主线程输出
		System.out.println(server.getBean());
	}
}
